﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DbSetupHelper.Common;

namespace DbSetupHelper
{
    /// <summary>
    /// Form used to display embeded sql to the user.
    /// </summary>
    public partial class SqlPreviewForm : Form
    {
        DBScript script;

        /// <summary>
        /// Initializes a new instance of the <see cref="SqlPreviewForm"/> class.
        /// </summary>
        /// <param name="script">The script.</param>
        public SqlPreviewForm(DBScript script)
        {
            InitializeComponent();

            this.script = script;
            script.BodyUpdated += new EventHandler(script_BodyUpdated);

            this.Text = script.ScriptFileName;
            rtbText.Text = script.ScriptBody;
        }

        void script_BodyUpdated(object sender, EventArgs e)
        {
            rtbText.Text = script.ScriptBody;
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
